package ast

import "strings"


func Id2String(id Identifier) string {
	return string(id.Name)
}

func String2Id(s string, node Node) Identifier {
	return Identifier {
		Node: node,
		Name: ([] rune)(s),
	}
}

func WrapTermAsExpr(term VariousTerm) Expr {
	return Expr {
		Node:     term.Node,
		Term:     term,
		Pipeline: nil,
	}
}

func WrapExprIntoTerm(expr Expr) VariousTerm {
	return VariousTerm {
		Node: expr.Node,
		Term: Block {
			Node:   expr.Node,
			Return: expr,
		},
	}
}

func GetDocContent(raw ([] Doc)) string {
	var buf strings.Builder
	for _, line := range raw {
		var t = string(line.RawContent)
		t = strings.TrimPrefix(t, "///")
		t = strings.TrimPrefix(t, " ")
		t = strings.TrimRight(t, " \r")
		buf.WriteString(t)
		buf.WriteRune('\n')
	}
	return buf.String()
}


